package cn.com.gridinfo.sooc.utils.versionHttp;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;


public class CheckNetState {
	/**
	 * 判断网络连接情况
	 * 
	 * @return
	 */
	public static boolean isConnectingToInternet(Context context) {
		ConnectivityManager connectivity = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		if (connectivity != null) {
			NetworkInfo[] info = connectivity.getAllNetworkInfo();
			if (info != null) {
				for (int i = 0; i < info.length; i++) {
					if (info[i].getState() == NetworkInfo.State.CONNECTED) {
						return true;
					}
				}
			}
		}
		return false;
	}
	
//	/**
//	 * 设置网络 暂时去掉
//	 *
//	 * @param context
//	 */
//	public static void setNetworkMethod(final Context context) {
//
//		Dialog.showCustomDialog(context, "设置网络", "网络连接不可用,是否进行设置?",
//				R.string.ok, R.string.cancel,
//				new DialogInterface.OnClickListener() {
//
//					@Override
//					public void onClick(DialogInterface dialog, int which) {
//
//						Intent intent = null;
//						// 判断手机系统的版本 即API大于10 就是3.0或以上版本
//						if (android.os.Build.VERSION.SDK_INT > 10) {
//							intent = new Intent(
//									android.provider.Settings.ACTION_WIRELESS_SETTINGS);
//						} else {
//							intent = new Intent();
//							ComponentName component = new ComponentName(
//									"com.android.settings",
//									"com.android.settings.WirelessSettings");
//							intent.setComponent(component);
//							intent.setAction("android.intent.action.VIEW");
//						}
//						context.startActivity(intent);
//
//
//					}
//				}, new DialogInterface.OnClickListener() {
//
//					@Override
//					public void onClick(DialogInterface dialog, int which) {
//						dialog.dismiss();
//
//					}
//				}, false);
////		(context);
////		builder.setTitle("网络设置提示")
////				.setMessage("网络连接不可用,是否进行设置?")
////				.setPositiveButton("设置", new DialogInterface.OnClickListener() {
////
////					@Override
////					public void onClick(DialogInterface dialog, int which) {
////						Intent intent = null;
////						// 判断手机系统的版本 即API大于10 就是3.0或以上版本
////						if (android.os.Build.VERSION.SDK_INT > 10) {
////							intent = new Intent(
////									android.provider.Settings.ACTION_WIRELESS_SETTINGS);
////						} else {
////							intent = new Intent();
////							ComponentName component = new ComponentName(
////									"com.android.settings",
////									"com.android.settings.WirelessSettings");
////							intent.setComponent(component);
////							intent.setAction("android.intent.action.VIEW");
////						}
////						context.startActivity(intent);
////					}
////				})
////				.setNegativeButton("取消", new DialogInterface.OnClickListener() {
////					@Override
////					public void onClick(DialogInterface dialog, int which) {
////						dialog.dismiss();
////					}
////				}).show();
//	}
}
